package com.vanzo.util;

import android.util.Log;

/**
 * Created by tisen on 2018/1/3.
 */

public class LogUtil {

    /**
     * Priority constant for the println method; use Log.v.
     */
    public static final int VERBOSE = 2;

    /**
     * Priority constant for the println method; use Log.d.
     */
    public static final int DEBUG = 3;

    /**
     * Priority constant for the println method; use Log.i.
     */
    public static final int INFO = 4;

    /**
     * Priority constant for the println method; use Log.w.
     */
    public static final int WARN = 5;

    /**
     * Priority constant for the println method; use Log.e.
     */
    public static final int ERROR = 6;


    private static boolean debug = true;
    private static String flag = "zts";

    public static void enable(boolean mDebug) {
        debug = mDebug;
    }

    public static void setFlag(String mFlag) {
        flag = mFlag;
    }

    public static void put(String TAG, String msg, int level) {
        if (debug) {
            switch (level) {
                case VERBOSE:
                    Log.v(TAG, flag + " : " + msg);
                    break;
                case DEBUG:
                    Log.d(TAG, flag + " : " + msg);
                    break;
                case INFO:
                    Log.i(TAG, flag + " : " + msg);
                    break;
                case WARN:
                    Log.w(TAG, flag + " : " + msg);
                    break;
                case ERROR:
                    Log.e(TAG, flag + " : " + msg);
                    break;
            }
        }
    }

    public static void put(String TAG, String msg, Throwable tr) {
        Log.e(TAG, flag + " : " + msg, tr);
    }

    public static void put(Object object, String msg, int level) {
        put(object.getClass().getSimpleName(), msg, level);
    }

    public static void put(Object object, String msg, Throwable tr) {
        put(object.getClass().getSimpleName(), msg, tr);
    }
}
